/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.caselogdocument.controller;

import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.caselogdocument.dto.CaseIogDocumentViewDto;
import com.icinfo.cloud.provider.punish.caselogdocument.dto.CaseIogDocumentViewPageQueryRequest;
import com.icinfo.cloud.provider.punish.caselogdocument.service.ICaseIogDocumentViewService;
import com.icinfo.cloud.provider.punish.caselogdocument.vo.CaseIogDocumentViewVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import com.icinfo.framework.tools.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述: 案件文书浏览日志表 case_log_document_view 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2023年02月21日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/caseiogdocument")
@Slf4j
public class CaseIogDocumentViewController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseIogDocumentViewController.class);

    @Autowired
    private ICaseIogDocumentViewService caseIogDocumentViewService;

    /**
     * 日志分页列表
     * @param request
     * @return
     */
    @PostMapping(value = "/getPageList")
    public Result<PageResponse<CaseIogDocumentViewVo>> getPageList(@RequestBody CaseIogDocumentViewPageQueryRequest request){
        PageResponse<CaseIogDocumentViewVo> pageList = caseIogDocumentViewService.getPageList(request);
        return Result.success(Constant.STRING_GET_SUCCESS, pageList);
    }

    /**
     * 新增文书日志
     * @param caseIogDocumentViewDto
     * @return
     */
    @PostMapping("/addCaseIogDocument")
    public Result addCaseIogDocument(@Validated  @RequestBody CaseIogDocumentViewDto caseIogDocumentViewDto){
        if(StringUtils.isNotBlank(caseIogDocumentViewDto.getDocumentKindCode())){
            try {
                caseIogDocumentViewService.addCaseIogDocument(caseIogDocumentViewDto);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return Result.success(Constant.STRING_SAVE_SUCCESS);
    }
}